name: NPM Tests

on:
  push:
    branches:
      - main
    paths:
      - frontend/
  pull_request:
    branches:
      - main
    paths:
      - frontend/**

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Setup Node.js environment
        uses: actions/setup-node@v2
        with:
          node-version: 19

      - name: Install dependencies
        run: npm ci
        working-directory: frontend

      - name: Run tests
        run: npm test
        working-directory: frontend
